package cheme.ProcessModel.Cmds;

import org.eclipse.gef.commands.Command;
import org.eclipse.ui.views.properties.IPropertySource;

public class SetPropertyCmd extends Command
{
	Object propertyId = null;
	IPropertySource targetObject = null;
	
	Object newValue = null;
	Object oldValue = null;
	
	public void execute()
	{
		oldValue = targetObject.getPropertyValue(propertyId);
		targetObject.setPropertyValue(propertyId, newValue);
	}
	
	public void setPropertyValue(Object newValue)
	{
		this.newValue = newValue;
	}
	
	public void setPropertyId(Object propertyId)
	{
		this.propertyId = propertyId;
	}

	public void setTargetObject(IPropertySource targetObject)
	{
		this.targetObject = targetObject;
	}

	public void undo()
	{
		targetObject.setPropertyValue(propertyId, oldValue);
	}
}
